import axios from "axios";
import { mockUrlInterceptor } from "./mockUrlInterceptmiddleware";

const request = axios.create({
    baseURL: "/api",
});

request.interceptors.request.use(
    (request) => {
        return mockUrlInterceptor(request);
    },
    (error) => {
        // Do something with request error
        return Promise.reject(error);
    }
);

request.interceptors.response.use(
    (response) => {
        return response.data;
    },
    (error) => {
        return Promise.reject(error);
    }
);

export { request };
